﻿using IntelligentAgriculture.Contracts.Interface.EliminationModelService;
using IntelligentAgriculture.WebAPI.Application.Command.DeathModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EliminationModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.EliminationModelCommandHandler
{
    public class EliminationDeleteRanCommandHandler : IRequestHandler<EliminationDeleteRanCommand, Results<int>>
    {
        private readonly IEliminationModelService _IeliminationModelService;
        public EliminationDeleteRanCommandHandler(IEliminationModelService ieliminationModelService)
        {
            _IeliminationModelService = ieliminationModelService;
        }

        public async Task<Results<int>> Handle(EliminationDeleteRanCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _IeliminationModelService.DeleteRange(request.ids);
                return Results<int>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
